package com.nineclock.sign.controller;

import com.nineclock.sign.service.SignPunchService;
import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.common.enums.ResponseEnum;
import com.nineclock.sign.SignPunchControllerApi;
import com.nineclock.sign.dto.SignPCListDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RequestMapping
@RestController
public class SignPunchController implements SignPunchControllerApi {

    @Autowired
    private SignPunchService signPunchService;
    @Override
    @GetMapping("/export")
    public void exportSignData(String startTime, String endTime) throws IOException {
            signPunchService.export(startTime, endTime);
    }

    @Override
    @GetMapping("/getDayCount")
    public Result<String> querySignCount() {
        String count=signPunchService.queryDayCount();
        return Result.success(count);
    }

    @Override
    @GetMapping("/sign")
    public Result<PageResult<SignPCListDTO>> queryMembers(String startTime,
                                                          @RequestParam(value = "page") Long page,
                                                          @RequestParam(value = "pageSize") Long pageSize,
                                                          String endTime) {
       PageResult<SignPCListDTO> pageResult=signPunchService.queryMembers(startTime,page,pageSize,endTime);
        return Result.success(pageResult);
    }

}
